package com.dongyoufa.senior1.month.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dongyoufa.senior1.month.dao.OrderDao;
import com.dongyoufa.senior1.month.entity.Detail;
import com.dongyoufa.senior1.month.entity.Order;
import com.dongyoufa.senior1.month.service.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class OrderServiceImpl implements OrderService{
	@Autowired
	private OrderDao orderDao;
	public Integer insertorder(Order order) {
		// TODO Auto-generated method stub
		int num = orderDao.insertorder(order);
		for (Detail detail : order.getDetails()) {
			detail.setOrderId(order.getId());
		}
		orderDao.insertdetail(order.getDetails());
		return num;
	}
	@Override
	public PageInfo<Order> getlist(Integer pageNum, Integer pageSize, Order order) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, pageSize);
		List<Order>  orders = orderDao.getlist(order);
		return new PageInfo<Order>(orders);
	}

}
